package com.tjsinfo.tjsoa.workTask.action;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.tjsinfo.tjsoa.workTask.bo.ITDailyWorkTaskBO;
import com.tjsinfo.tjsoa.workTask.vo.TDailyWorkTask;

public class WorkTaskToAction extends Action {
	private ITDailyWorkTaskBO workTaskBo;

	public void setWorkTaskBo(ITDailyWorkTaskBO workTaskBo) {
		this.workTaskBo = workTaskBo;
	}
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		// TODO Auto-generated method stub
		String method = request.getParameter("method");
		String forword = "form";
		String id = request.getParameter("id");
		if("recipientUserid".equals(method)){
			TDailyWorkTask tdwt = workTaskBo.findById(id);
			if(tdwt.getCurrentStatus().equals(0)){
				tdwt.setCurrentStatus(1);
				workTaskBo.update(tdwt);
			}
			request.setAttribute("tdwt", tdwt);
			request.setAttribute("method", method);
			forword="content";
		}else if("dividerUserid".equals(method)){
			TDailyWorkTask tdwt = workTaskBo.findById(id);
			request.setAttribute("tdwt", tdwt);
			request.setAttribute("method", method);
			forword="content";
		}
		
		return mapping.findForward(forword);
	}
}
